package controller;

import Dao.UserDao;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class UserDeleteServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int result = 0;
        UserDao dao = new UserDao();
        String userId = request.getParameter("userId");

        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        result = dao.delete(Integer.parseInt(userId));
        if (result == 1){
            out.print("<font style='color:red;font-size:40'>用户信息删除成功！</font>");
        } else{
            out.print("<font style='color:red;font-size:40'>用户信息删除失败！</font>");
        }
    }
}
